home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / MoreHardware / GALer20.lha / GALer20 / Source / GALerTest / GALer.h next >
Encoding:
C/C++ Source or Header  |  1996-04-05  |  18.0 KB  |  510 lines

  1. /******************************************************************************
  2. ** GALer.h
  3. *******************************************************************************
  4. **
  5. ** author:   Christian Habermann
  6. ** date:     07.02.1995
  7. **
  8. *******************************************************************************
  9. **
  10. ** description:
  11. ** This file includes some definitions and structures used by GALer.
  12. **
  13. *******************************************************************************
  14. **
  15. ** changes:
  16. ** date     |     author     |  comment
  17. **          |                |
  18. **          |                |
  19. ******************************************************************************/
  20.  
  21.  
  22.  
  23.  
  24.  
  25. /****************************** include files ********************************/
  26.  
  27. #ifndef  EXEC_TYPES_H
  28. #include <exec/types.h>
  29. #endif
  30.  
  31. #ifndef  __STDIO_H
  32. #include <stdio.h>
  33. #endif
  34.  
  35.  
  36.  
  37.  
  38.  
  39. /******************************* definitions *********************************/
  40.  
  41. #define         GAL16V8         1               /* GAL types */
  42. #define         GAL20V8         2
  43. #define         GAL22V10        3
  44. #define         GAL20RA10       4
  45. #define         UNKNOWN         5
  46. #define         NOT_SPECIFIED   6
  47.  
  48.  
  49. #define         HW_GALER_1_0    1               /* hardware versions */
  50. #define         HW_GALER_1_2    2
  51. #define         HW_GALER_1_3    3
  52. #define         HW_ELEKTOR_II   10
  53.  
  54.  
  55. #define         EDITOR_STR_SIZE 25              /* string size for editor */
  56.  
  57.  
  58. #define         IC1              3              /* IC numbers */
  59. #define         IC2             11              /* IC2 only for Elektor- and */
  60. #define         IC3              0              /* Maxon-GAL-programmer      */
  61. #define         IC4              1
  62. #define         IC5              2
  63. #define         IC6a             0
  64. #define         IC6c             4
  65. #define         IC7              1
  66. #define         IC10            10
  67.  
  68.  
  69. #define         ON              1               /* LED status */
  70. #define         OFF             0
  71.  
  72. #define         YES             1
  73. #define         NO              0
  74.  
  75. #define         PROG            1               /* GAL mode */
  76. #define         VERIFY          0
  77.  
  78. #define         LOW             0
  79. #define         HIGH            1
  80. #define         INPUT_PIN       0
  81. #define         OUTPUT_PIN      1
  82.  
  83. #define         CONT_REQ        0               /* types of requester */
  84. #define         INFO_REQ        1
  85. #define         ERR_REQ         2
  86. #define         GALTYPE_REQ     3
  87. #define         ERASE_REQ       5
  88.  
  89. #define         LOAD            0               /* types of file-requesters */
  90. #define         SAVE            1
  91.  
  92.                                              /* duration of the STR strobe */
  93. #define         _80MS           80000L       /* in micros for programming  */
  94. #define         _10MS           10000L       /* and erasing                */
  95. #define         _40MS           40000L
  96. #define         _50MS           50000L
  97. #define         _100MS          100000L
  98. #define         VERIFY_TIME     5L            /* read */
  99.  
  100.  
  101.                                               /* voltages */
  102. #define         V12_00          4             /* 12.00V */
  103. #define         V14_00          3             /* 14.00V */
  104. #define         V14_50          2             /* 14.50V */
  105. #define         V15_75          1             /* 15.75V */
  106. #define         V16_50          0             /* 16.50V */
  107.  
  108.  
  109. #define         COPYGAL         1       /* used by ProgJedecToGAL function */
  110. #define         PROGGAL         2
  111.  
  112.                                         /* GAL16V8 */
  113. #define LOGIC16         0               /* location of the fuses */
  114. #define XOR16           2048            /* in the JEDEC file     */
  115. #define SIG16           2056
  116. #define AC116           2120
  117. #define PT16            2128
  118. #define SYN16           2192
  119. #define AC016           2193
  120. #define NUMOFFUSES16    2194
  121.                                         /* GAL20V8 */
  122. #define LOGIC20         0               /* location of the fuses */
  123. #define XOR20           2560            /* in the JEDEC file     */
  124. #define SIG20           2568
  125. #define AC120           2632
  126. #define PT20            2640
  127. #define SYN20           2704
  128. #define AC020           2705
  129. #define NUMOFFUSES20    2706
  130.  
  131.                                         /* GAL22V10 */
  132. #define NUMOFFUSES22V10 5892            /* location of the fuses */
  133. #define XOR22V10        5808            /* in the JEDEC file     */
  134. #define SYN22V10        5809
  135. #define SIG22V10        5828
  136.  
  137.                                         /* GAL20RA10 */
  138. #define NUMOFFUSES20RA10 3274           /* location of the fuses */
  139. #define XOR20RA10        3200           /* in the JEDEC file     */
  140. #define SIG20RA10        3210
  141.  
  142.  
  143. #define LOGIC16_SIZE    2048            /* number of bits for XOR etc. */
  144. #define LOGIC20_SIZE    2560
  145. #define LOGIC22V10_SIZE 5808
  146. #define LOGIC20RA10_SIZE 3200
  147. #define ROW_SIZE_16V8   64
  148. #define ROW_SIZE_20V8   64
  149. #define ROW_SIZE_22V10  132
  150. #define ROW_SIZE_20RA10 80
  151. #define XOR_SIZE        8
  152. #define SIG_SIZE        64
  153. #define AC1_SIZE        8
  154. #define PT_SIZE         64
  155. #define SYN_SIZE        1
  156. #define AC0_SIZE        1
  157. #define ACW_SIZE        82              /* architecture control word (ACW) */
  158.  
  159. #define MAX_FUSE_ADR16          31      /* addresses of the GALs */
  160. #define SIG_ADR16               32      /* (fuer Fan-Post :-))   */
  161. #define MAX_FUSE_ADR20          39
  162. #define SIG_ADR20               40
  163. #define MAX_FUSE_ADR22V10       43
  164. #define SIG_ADR22V10            44
  165. #define MAX_FUSE_ADR20RA10      39
  166. #define SIG_ADR20RA10           40
  167. #define ACW_ADR                 60
  168. #define SECURITY_ADR            61
  169. #define ERASE_ADR               63
  170.  
  171.  
  172.                             /* the following definitions are */
  173.                             /* used by GALer's assembler     */
  174.  
  175. #define ASSEMBLER       0         /* assemble whole file -> JEDEC       */
  176. #define OPTIMIZER       1         /* assemble up to the equationd, then */
  177.                                   /* return (used by the optimizer )    */
  178.  
  179.                                   /* output's polarity: */
  180. #define ACTIVE_LOW      0             /* pin is high-active */
  181. #define ACTIVE_HIGH     1             /* pin is low-active  */
  182.  
  183.                                   /* type of the pin: */
  184. #define NOTUSED         0             /* pin not used up to now */
  185. #define NOTCON          0             /* pin not used           */
  186. #define INPUT           2             /* input                  */
  187. #define COMOUT          3             /* combinational output   */
  188. #define TRIOUT          4             /* tristate output        */
  189. #define REGOUT          5             /* register output        */
  190. #define COM_TRI_OUT     6             /* either tristate or     */
  191.                                       /* combinational output   */
  192.  
  193.                                   /* tristate control: */
  194. #define NO_TRICON       0             /* no tristate control defined       */
  195. #define TRICON          1             /* tristate control defined          */
  196. #define TRI_VCC         2             /* permanent low  impedance          */
  197. #define TRI_GND         3             /* permanent high impedance          */
  198. #define TRI_PRO         4             /* tristate control via product term */
  199.  
  200.  
  201. #define NC_PIN          30
  202.  
  203. #define MODE1           1               /* modes (SYN, AC0) */
  204. #define MODE2           2
  205. #define MODE3           3
  206.  
  207.  
  208. #define MAX_SUFFIX_SIZE 6               /* max. string length of a legal */
  209.                                         /* suffix */
  210.  
  211.  
  212.                             /* the following definitions are */
  213.                             /* used by GALer's optimizer     */
  214.  
  215. #define NEGATION        0x80            /* bit 7 = 1 if pinname is */
  216.                                         /* introduced by a'/'      */
  217. #define EQUASKIP        0xFE            /* skip equation   */
  218. #define EQUAEND         0xFF            /* end of equation */
  219. #define EQUASEND        0x00            /* end of equation part, the next */
  220.                                         /* word should be DESCRIPTION     */
  221.  
  222. #define ENTRY_SIZE      256             /* number of entries per buffer */
  223.  
  224. #define SIZE_OF_EQUASTRING 80
  225.  
  226.  
  227.  
  228. #define FIRST_GAL_GADGET_ID 1           /* lowest ID for the GAL gadgets */
  229.                                         /* (must be > 0)                 */
  230.  
  231.  
  232.                                         /* menu IDs */
  233.  
  234. enum {  FIRST_MENU_ID = 100,
  235.  
  236.         MEN_PROJECT, MEN_ABOUT, MEN_HARDVER, MEN_VER11, MEN_VER12,
  237.         MEN_VER13, MEN_VERELEKTOR, MEN_SAVECONFIG, MEN_QUIT,
  238.  
  239.         MEN_GALTYPE, MEN_16V8, MEN_20V8, MEN_22V10, MEN_20RA10, MEN_TYPEREQ,
  240.  
  241.         MEN_GAL, MEN_PROG, MEN_COPY, MEN_ERASE, MEN_CMP, MEN_CLEAR,
  242.         MEN_SETSEC, MEN_TESTSEC, MEN_WRITE,
  243.  
  244.         MEN_GALASM, MEN_ASSEMBLE,
  245.  
  246.         MEN_GALDIS, MEN_READSIG, MEN_READACW, MEN_READINFO, MEN_READJED,
  247.         MEN_READJEDPARA, MEN_REASM,
  248.  
  249.         MEN_TOOLS, MEN_SHOWPIN, MEN_CLEARPIN, MEN_CALLCHECKER, MEN_OPTIMIZER,
  250.         MEN_EDIT, MEN_CALLEDIT, MEN_HELP,
  251.  
  252.         MEN_CHECKER, MEN_EXITCHECKER,
  253.  
  254.         LAST_MENU_ID
  255.      };
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262. /******************************** structures *********************************/
  263.  
  264.                                         /* this structure is used to store   */
  265.                                         /* GALer's configuration             */
  266. struct  Configuration { BYTE GALType;          /* type of GAL                */
  267.                         BYTE GALTypeReq;       /* TRUE=Requester für GAL-Typ */
  268.                         BYTE GenJedec;         /* generate JEDEC file?       */
  269.                         BYTE GenFuse;          /* generate fuse file?        */
  270.                         BYTE GenChip;          /* generate chip file?        */
  271.                         BYTE GenPin;           /* generate pin file?         */
  272.                         BYTE AutoSave;         /* save automatically?        */
  273.                         BYTE AutoGAL;          /* get type of GAL automatic.?*/
  274.                         BYTE ProgEmptyTest;    /* blank test before prog.?   */
  275.                         BYTE ProgVerify;       /* verify after programming?  */
  276.                         BYTE CopyEmptyTest;    /* blank test before copying? */
  277.                         BYTE CopyVerify;       /* verify after copying?      */
  278.                         BYTE EraseEmptyTest;   /* blank test after erasing?  */
  279.                         BYTE JedecSecBit;      /* set security bit in JEDEC? */
  280.                         BYTE JedecFuseChk;     /* calc. fuse checksum?       */
  281.                         BYTE JedecFileChk;     /* calc. file checksum?       */
  282.                         BYTE HardwareVersion;  /* used hardware version      */
  283.                         BYTE EdWBToFront;      /* WB to front when start. ED */
  284.                         char EditorStr[EDITOR_STR_SIZE];
  285.                       };
  286.  
  287.  
  288.                                         /* this structure is used to store */
  289.                                         /* the fuses in a kind of JEDEC    */
  290.                                         /* format                          */
  291.  
  292. struct  JedecStruct { BYTE GALLogic[5808];      /*max. size of fuse matrix */
  293.                       BYTE GALXOR  [10];        /* XOR bits                */
  294.                       BYTE GALSig  [64];        /* signature               */
  295.                       BYTE GALAC1  [8];         /* AC1 bits                */
  296.                       BYTE GALPT   [64];        /* product term disable    */
  297.                       BYTE GALSYN;              /* SYN bit                 */
  298.                       BYTE GALAC0;              /* AC0 bit                 */
  299.                       BYTE GALS1   [10];        /* S1 bits for 22V10       */
  300.                     };
  301.                     
  302.  
  303.                                         /* used to store infos about a pin */
  304. struct  Pin             { BYTE p_Neg;        /* polarity of pin */
  305.                           BYTE p_Pin;        /* pin number      */
  306.                         };
  307.  
  308.                                         /* used to store infos about an OLMC */
  309.  
  310. struct  GAL_OLMC        { BYTE Active;       /* output's polarity           */
  311.                           BYTE PinType;      /* type of pin (input,...)     */
  312.                           BYTE TriCon;       /* user def. tristate control? */
  313.                           BYTE Clock;        /* user def. clock equation?   */
  314.                           BYTE ARST;         /* user def. ARST equation?    */
  315.                           BYTE APRST;        /* user def. APRST equation?   */
  316.                           BYTE FeedBack; };  /* is there a feedback?        */
  317.  
  318.  
  319.                                         /* this structure is used to store  */
  320.                                         /* some datas in a chained list     */
  321.                                         /* e.g. the coded equations for the */
  322.                                         /* optimizer                        */
  323.  
  324. struct  Buffer  { struct Buffer *Next;
  325.                   struct Buffer *Prev;
  326.                   UBYTE  Entries[ENTRY_SIZE];   /* data area */
  327.                 };
  328.                                                     
  329.                                         /* used to store results and     */
  330.                                         /* parameters of functions       */
  331.                                         /* which deal with chained lists */
  332.  
  333. struct  ActBuffer  { struct Buffer *ThisBuff;  /* pointer to current buffer */
  334.                      UBYTE       *Entry;       /* pointer to data area      */
  335.                      UBYTE       *BuffEnd;     /* pointer to the end of the */
  336.                    };                          /* buffer                    */
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343. /*************************** function declartions ****************************/
  344.  
  345.  
  346. /* Port.asm */
  347. void    InitHardware(void);
  348. void    EnableOutput(void);
  349. void    DisableOutput(void);
  350. void    InitParPort(void);
  351. void    RestoreParPort(void);
  352. void    WriteByte(int, int);
  353. int     ReadByte(int);
  354. void    VeditOn(void);
  355. void    VeditOff(void);
  356. void    LED(int);
  357. void    EnableVcc(void);
  358. void    DisableVcc(void);
  359. void    EnableVEdit(void);
  360. void    DisableVEdit(void);
  361. void    SetRow(int);
  362. void    SDIn(int);
  363. int     SDOut(void);
  364. void    Clock(void);
  365. void    STRImpuls(long);
  366. void    EditMode(int);
  367. void    ExitEditMode(void);
  368. void    SetPV(int);
  369. void    SetVolt(int);
  370. void    SetGAL(int);
  371. void    SetPESSAVE(int);
  372. void    SetERASE(int);
  373. void    SetCLR(int);
  374. void    SetBE(int);
  375. void    SetARCH(int);
  376. void    SetANDBE(int);
  377.  
  378.  
  379. /* GAL.c */
  380. void  ProgramGAL(void);
  381. void  CopyGAL(void);
  382. int   CheckGAL(void);
  383. void  TestSecurity(void);
  384. void  Compare(void);
  385. void  PrintACW(void);
  386. void  PrintSignature(void);
  387. int   ProgJedecToGAL(int mode);
  388. void  ReadGALToJedec(void);
  389. void  SetSecurity(int flag);
  390. void  Loeschen(void);
  391. void  EraseIt(void);
  392. void  Leertest(void);
  393.  
  394.  
  395. /*GALasm .c */
  396. int   AssembleInputFile(int OpMode);
  397. void  SetAND(int row, int pinnum, int negation);
  398. void  IsPinName(UBYTE *pinnames, int numofpins);
  399. int   GetNextChar(void);
  400. int   GetNextLine(void);
  401. void  AsmError(int errornum, int pinnum);
  402. void  WriteChipFile(void);
  403. void  WritePinFile(void);
  404. void  WriteFuseFile(void);
  405. void  WriteSpaces(FILE *fp, int numof);
  406. void  WriteRow(FILE *fp, int row);
  407. int   IsOR(char);
  408. int   IsAND(char);
  409. int   IsNEG(char);
  410. void  Is_AR_SP(UBYTE *ptr);
  411.  
  412.  
  413. /* Optimizer.c */
  414. int  Optimizer(void);
  415. struct ActBuffer GetProdTermStart(struct ActBuffer pos);
  416. void  KillProdTerm(struct ActBuffer term);
  417. int   OptimizeEqua(struct ActBuffer buff);
  418. int   Resolvente(struct ActBuffer optstart, struct ActBuffer optend, struct ActBuffer alteSchicht);
  419. int   NumOfVar(struct ActBuffer term);
  420. int   AddResolvente(struct ActBuffer pos1, struct ActBuffer pos2, struct ActBuffer equastart, struct ActBuffer *equaend);
  421. int   SearchVar(struct ActBuffer *, struct ActBuffer, UBYTE);
  422. int   WriteNewSource(struct ActBuffer buff, UBYTE *equastart, UBYTE *equaend);
  423. int   CopyEqua(struct ActBuffer from_buff, struct ActBuffer to_buff);
  424. int   PrintEqua(struct ActBuffer buff, struct ActBuffer *filebuff);
  425. int   GetNext(struct ActBuffer *buff);
  426. int   GetNextEqua(struct ActBuffer *buff);
  427. void  PrintOptText(UBYTE *txt);
  428. void  ScrollRequester(void);
  429. int   TranslateEqua(struct ActBuffer *buff);
  430.  
  431.  
  432. /* Pruefer.c */
  433. void  Pruefer(struct Gadget *gad, USHORT gadID);
  434. void  SetLevel(USHORT gadID, int level);
  435. void  CheckOutput(void);
  436. void  TogglePruefer(void);
  437. void  SetSymbolGAL(int type);
  438. void  PrintPinNames(void);
  439. void  ClearPinNames(void);
  440.  
  441.  
  442. /* GAL2.c */
  443. UBYTE GetByte(UBYTE *ptr);
  444. int   ReadGALParameter(int checkflag);
  445. void  GALInfo(void);
  446. int   GALAType(void);
  447.  
  448.  
  449. /* Sub.c */
  450. void  Schreibverhalten(void);
  451. void  JedecRequester(void);
  452. void  About(void);
  453. int   mystrcmp(char *cptr1, char *cptr2);
  454. int   MyFileReq(char *headtxt, char *showtxt, int showreq, int mode);
  455. int   MyRequest(int mode, UBYTE *text);
  456. int   AsmRequester(void);
  457. long  FileSize(UBYTE *filename);
  458. int   ReadFile(UBYTE *filename, LONG filesize, UBYTE *filebuff);
  459. void  ErrorReq(int errornum);
  460. void  PrintText(UBYTE *text, int newline);
  461. void  PrintErrorLine(int line);
  462. void  LoadConfig(void);
  463. void  SaveConfig(void);
  464. void  SetGALType(int galtype);
  465. int   AddByte(struct ActBuffer *buff, UBYTE code);
  466. int   AddString(struct ActBuffer *buff, UBYTE *strnptr);
  467. void  IncPointer(struct ActBuffer *buff);
  468. void  DecPointer(struct ActBuffer *buff);
  469. void  FreeBuffer(struct Buffer *buff);
  470. void  SelectEditor(void);
  471. void  CallEditor(void);
  472. void  WaitForTimer(ULONG micro);
  473.  
  474.  
  475. /* Reasm.c */
  476. int    CheckPinNames(void);
  477. int    PinNameRequester(int galtype);
  478. int    RowActive(int row, int galtype);
  479. int    OLMCOutput(int olmc, int mode);
  480. int    MakeEquation(struct ActBuffer *buff, int olmc, int colsize,
  481.                     int mode, int rowoffset, int numofrows);
  482. int    Reasm(struct ActBuffer buff);
  483. void   Reassembler(void);
  484. void   ReasmError(int errornum, int pinnum);
  485. UBYTE *PinNamePtr(int pinnum, struct Gadget *gadget);
  486.  
  487.  
  488.  
  489. /* Jedec.c */
  490. void  PutJedec(void);
  491. int   FileChecksum(struct ActBuffer buff);
  492. int   FuseChecksum(int galtype);
  493. int   MakeJedecBuff(struct ActBuffer buff, int galtype);
  494. void  WriteJedecFile(int galtype);
  495. int   SearchNextChar(void);
  496. int   SearchNextAsterix(void);
  497. int   GetJedec(UBYTE *jedecfile);
  498. void  JedecError(int errornum, int flag);
  499.  
  500.  
  501. /* Localize.c */
  502. void  LocalizeText(void);
  503.  
  504.  
  505. /* Help.c */
  506. void  HelpOnMainMenu(UWORD menuNumber);
  507. void  HelpOnCheckerMenu(UWORD menuNumber);
  508. void  Help(void);
  509.  
  510.